.switch {
  --button-width: 3vw;
  --button-height: 3vh;
  --toggle-diameter: 3vh;
  --button-toggle-offset: calc(
    (var(--button-height) - var(--toggle-diameter)) / 2
  );
  --toggle-shadow-offset: 10px;
  --toggle-wider: 3em;
  --color-grey: #cccccc;
  --color-green: #4296f4;
  cursor: pointer;

  .slider {
    display: inline-block;
    width: var(--button-width);
    height: var(--button-height);
    background-color: var(--color-grey);
    border-radius: calc(var(--button-height) / 2);
    position: relative;
    transition: 0.3s all ease-in-out;
  }

  .slider::after {
    content: "";
    display: inline-block;
    width: var(--toggle-diameter);
    height: var(--toggle-diameter);
    background-color: #fff;
    border-radius: calc(var(--toggle-diameter) / 2);
    position: absolute;
    top: var(--button-toggle-offset);
    left: var(--button-toggle-offset);
    box-shadow: var(--toggle-shadow-offset) 0
      calc(var(--toggle-shadow-offset) * 4) rgba(0, 0, 0, 0.1);
    transition: 0.3s all ease-in-out;
  }

  input[type="checkbox"]:checked + .slider {
    background-color: var(--color-green);
  }

  input[type="checkbox"]:checked + .slider::after {
    left: calc(
      var(--button-width) - var(--toggle-diameter) - var(--button-toggle-offset)
    );
    box-shadow: calc(var(--toggle-shadow-offset) * -1) 0
      calc(var(--toggle-shadow-offset) * 4) rgba(0, 0, 0, 0.1);
  }

  input[type="checkbox"] {
    display: none;
  }

  input[type="checkbox"]:active + .slider::after {
    width: var(--toggle-wider);
  }

  input[type="checkbox"]:checked:active + .slider::after {
    left: calc(
      var(--button-width) - var(--toggle-wider) - var(--button-toggle-offset)
    );
  }
}
